﻿/*

Copyright (c) 2009, Stephen Remde
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the <organization> nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY STEPHEN REMDE ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL STEPHEN REMDE BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Graphs;
using System.Windows.Media;

namespace ConceptLink
{
    /// <summary>
    /// defines a search context and a method to perform the search
    /// </summary>
    abstract class SearchContext
    {
        /// <summary>
        /// article searching from
        /// </summary>
        public Article From { get; protected set; }

        /// <summary>
        /// article searching to
        /// </summary>
        public Article To { get; protected set; }

        protected SearchContext()
        {
        }

        /// <summary>
        /// number of iterations performed
        /// </summary>
        public int Iterations { get; protected set; }

        /// <summary>
        /// the graph we are to display information on
        /// </summary>
        public Graph Graph { get; protected set; }

        /// <summary>
        /// the current search path
        /// </summary>
        public Article[] Path { get; protected set; }

        /// <summary>
        /// has a path been found
        /// </summary>
        public bool Compelete { get; set; }
                
        /// <summary>
        /// a delegate to be called when a step has been compelted
        /// </summary>
        /// <param name="sender"></param>
        public delegate void StepComplete(SearchContext sender);

        /// <summary>
        /// performs an iteration of the search and calls the callback once completed
        /// </summary>
        /// <param name="callback"></param>
        public abstract void Step(StepComplete callback);



        /// <summary>
        /// colour the graph to show distance from the destination
        /// </summary>
        public bool ColorToDestination { get { return !ColorFromStart; } set { ColorFromStart = !value; } }

        /// <summary>
        /// colour the graph to show distance from the start
        /// </summary>
        public bool ColorFromStart { get; set; }
        
        /// <summary>
        /// label the links
        /// </summary>
        public bool ShowTextOnLinks { get; set; }

        /// <summary>
        /// colour the current search path a different colour
        /// </summary>
        public bool ColorCurrentPath { get; set; }          

    }
}
